package dto

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/comment"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type CommentGetPageReq struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required" search:"type:exact;column:tenant_id;table:comment"`
	BasicId        int    `json:"basic_id" comment:"直播间id" validate:"required" search:"type:exact;column:basic_id;table:comment"`
	BindId         string `json:"bind_id" comment:"直播间id"  search:"type:exact;column:bind_id;table:comment"`
}

type CommentOrder struct {
	Id           string `form:"idOrder"  search:"type:order;column:id;table:comment"`
	TenantId     string `form:"tenant_idOrder"  search:"type:order;column:tenant_id;table:comment"`
	BasicId      string `form:"basic_idOrder"  search:"type:order;column:basic_id;table:comment"`
	ParentId     string `form:"parent_idOrder"  search:"type:order;column:parent_id;table:comment"`
	ToCommentId  string `form:"to_comment_idOrder"  search:"type:order;column:to_comment_id;table:comment"`
	Likes        int    `form:"likesOrder"  search:"type:order;column:likes;table:comment"`
	CommentIp    string `form:"comment_ipOrder"  search:"type:order;column:comment_ip;table:comment"`
	Account      string `form:"accountOrder"  search:"type:order;column:account;table:comment"`
	UserName     string `form:"user_nameOrder"  search:"type:order;column:user_name;table:comment"`
	Content      string `form:"contentOrder"  search:"type:order;column:content;table:comment"`
	CommentState string `form:"comment_stateOrder"  search:"type:order;column:comment_state;table:comment"`
	CreateBy     string `form:"createByOrder"  search:"type:order;column:create_by;table:comment"`
	UpdateBy     string `form:"updateByOrder"  search:"type:order;column:update_by;table:comment"`
	CreateTime   string `form:"create_timeOrder"  search:"type:order;column:create_time;table:comment"`
	UpdateTime   string `form:"update_timeOrder"  search:"type:order;column:update_time;table:comment"`
}

func (m *CommentGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type CommentInsertReq struct {
	Id           int    `json:"-" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户" validate:"required"`
	BasicId      int    `json:"basic_id" comment:"直播间id"`
	ParentId     int    `json:"parent_id" comment:"父级id"`
	ToCommentId  int    `json:"to_comment_id" comment:"回复目标评论id"`
	Likes        int    `json:"likes" comment:"点赞数"`
	CommentIp    string `json:"comment_ip" comment:"评论ip"`
	Account      string `json:"account" comment:"账户" validate:"required"`
	UserName     string `json:"user_name" comment:"用户昵称"`
	Content      string `json:"content" comment:"评论内容" validate:"max=300"`
	CommentState int    `json:"comment_state" comment:"1待审核 2未通过 3通过 4禁言"`
	CommentType  int    `json:"comment_type" comment:"1全局直播 2直播调度"`
	HeadImgUrl   string `json:"head_img_url" comment:"用户头像"`
	MarkTime     int    `json:"mark_time" comment:"标注时间"`
	BindId       string `json:"bind_id" comment:"关联id"`
	FirstId      int    `json:"first_id" comment:"第一级别id"`
	common.ModelTime
	common.ControlBy
}

func (s *CommentInsertReq) Generate(model *comment.Comment) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.BasicId = s.BasicId
	model.ParentId = s.ParentId
	model.ToCommentId = s.ToCommentId
	model.Likes = 0
	model.CommentIp = s.CommentIp
	model.Account = s.Account
	model.UserName = s.UserName
	model.Content = s.Content
	model.CommentState = 1
	model.CreateBy = s.TenantId // 添加这而，需要记录是被谁创建的
	model.CreateBy = s.TenantId
	model.CreateTime = now
	model.UpdateTime = now
	model.HeadImgUrl = s.HeadImgUrl
	model.CommentType = s.CommentType
	model.MarkTime = s.MarkTime
	model.BindId = s.BindId
	model.FirstId = s.FirstId
}

func (s *CommentInsertReq) GetId() interface{} {
	return s.Id
}

type CommentUpdateReq struct {
	Id           int    `uri:"id" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户"`
	BasicId      int    `json:"basic_id" comment:"直播间id"`
	ParentId     int    `json:"parent_id" comment:"父级id"`
	ToCommentId  int    `json:"to_comment_id" comment:"回复目标评论id"`
	Likes        int    `json:"likes" comment:"点赞数"`
	CommentIp    string `json:"comment_ip" comment:"评论ip"`
	Account      string `json:"account" comment:"账户"`
	UserName     string `json:"user_name" comment:"用户昵称"`
	Content      string `json:"content" comment:"评论内容"`
	CommentState int    `json:"comment_state" comment:"1未通过 2通过 3 禁言"`
	CreateTime   int64  `json:"create_time" comment:"创建时间"`
	UpdateTime   int64  `json:"update_time" comment:"更新时间"`
	CommentType  int    `json:"comment_type" comment:"1全球直播 2直播调度"`
	common.ControlBy
}

func (s *CommentUpdateReq) Generate(model *comment.Comment) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.TenantId = s.TenantId
	model.BasicId = s.BasicId
	model.ParentId = s.ParentId
	model.ToCommentId = s.ToCommentId
	model.Likes = s.Likes
	model.CommentIp = s.CommentIp
	model.Account = s.Account
	model.UserName = s.UserName
	model.Content = s.Content
	model.CommentState = s.CommentState
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
	model.CreateTime = s.CreateTime
	model.UpdateTime = s.UpdateTime
	model.CommentType = s.CommentType
}

func (s *CommentUpdateReq) GetId() interface{} {
	return s.Id
}

// CommentGetReq 功能获取请求参数
type CommentGetReq struct {
	Id int `uri:"id"`
}

func (s *CommentGetReq) GetId() interface{} {
	return s.Id
}

// CommentDeleteReq 功能删除请求参数
type CommentDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *CommentDeleteReq) GetId() interface{} {
	return s.Ids
}

type CommentReviewReq struct {
	Id           int `json:"id" validate:"required"`
	CommentState int `json:"comment_state" comment:"评论状态 1待审核 2未通过 3通过 4禁言" validate:"gt=0"`
	common.ControlBy
}

type GetAllReviews struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required"`
	BasicId        int    `json:"basic_id" comment:"直播间id" validate:"required"`
	LastId         int    `json:"last_id" comment:"上一个分页的最后一条数据id"`
}

type GetAllReplies struct {
	TenantId string `json:"tenant_id" comment:"租户"`
	BindId   string `json:"bind_id" comment:"关联id"`
	BasicId  int    `json:"basic_id" comment:"关联id"`
	ParentId int    `json:"parent_id" comment:"父级id"`
}

type GetCommentList struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id" comment:"租户"`
	BindId         string `json:"bind_id" comment:"关联id"`
	UserName       string `json:"user_name" comment:"评论人"`
}

type DeleteComment struct {
	Ids []int `json:"ids" comment:"ids"`
}
